package cn.jsp.reflect;

import java.lang.reflect.Field;

public class ReflectDemo {
  public static void main(String[] args) throws Exception {
    Class<SimpleObj> clazz= SimpleObj.class;
    Object obj=clazz.getDeclaredConstructor().newInstance();//new SimpleObj()
    //set
    Field field=clazz.getDeclaredField("age");
    field.setAccessible(true);
    System.out.println(field.get(obj));
    field.set(obj,21);
    System.out.println(obj);
  }
}
